//
//  ICMProxyPreviewViewController.m
//  ICrEAM
//
//  Created by Cty on 2016/11/10.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "ICMProxyPreviewViewController.h"
#import "ICMProxyPreviewView.h"
#import "BalancePresentController.h"
@interface ICMProxyPreviewViewController ()<UIScrollViewDelegate,BalancePresentControllerDeleagte>

@property(nonatomic, strong) UIScrollView *previewList;//scrollview
@property(nonatomic, strong) ICMProxyPreviewView *preview;//预览view

@end

@implementation ICMProxyPreviewViewController

- (UIScrollView *)previewList
{
    if(!_previewList)
    {
        _previewList = [[UIScrollView alloc]initWithFrame:CGRectMake(0, ActualHeight(40), ScreenWidth, ScreenHeight - NavBarAndStatusHeight-ActualHeight(40))];
        _previewList.delegate = self;
    }
    return _previewList;
}

- (ICMProxyPreviewView *)preview
{
    if(!_preview)
    {
        _preview = [[ICMProxyPreviewView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ActualHeight(4400))];
//        _preview = [[ICMProxyPreviewView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
    }
    return _preview;
}

-(void)viewWillAppear:(BOOL)animated{

    [super viewWillAppear: animated];
    
    
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = BackgroundColor_White;
    UIView *topBar = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ActualHeight(40))];
    
    topBar.backgroundColor = Color(0xE5EBEB);
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    //委托书预览
    UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(ActualWidth(80), 0, ActualWidth(100), ActualHeight(40))];
    
    title.text = @"委托书预览";
    title.textColor = TitleColor;
    title.textAlignment = NSTextAlignmentCenter;
    title.font = NaviFont;
    
    [topBar addSubview:title];
    
    UIButton *btnPrint = [[UIButton alloc]initWithFrame:CGRectMake(ActualWidth(930), ActualHeight(7), ActualWidth(25), ActualHeight(25))];
    UIImage *img = [UIImage imageNamed:GetCar_Print];
    [btnPrint setBackgroundImage:img forState:normal];
    [btnPrint addTarget:self action:@selector(clickPrintButton) forControlEvents:UIControlEventTouchUpInside];
    UIView *underLine = [[UIView alloc]initWithFrame:CGRectMake(ActualWidth(80), ActualHeight(39), ActualWidth(100), 1)];
    
    underLine.backgroundColor = TitleColor;
    
    [topBar addSubview:underLine];
    [topBar addSubview:btnPrint];
    [self.view addSubview:topBar];
    
    self.preview.isFinishCheckPush=self.isFinishCheck;
    self.preview.activityModels = self.activityModels;
    self.preview.repairPartsArrayModel = self.repairPartsArrayModel;
    self.preview.proxyBasicInfoModel = self.proxyBasicInfoModel;
    self.preview.repairMaintenancesModel = self.repairMaintenancesModel;
    self.preview.stationsArrayModel = self.stationsModel;
    [self.preview setUpChildView];
    self.preview.frame = CGRectMake(0, 0, ScreenWidth, self.preview.endFrame.origin.y+self.preview.endFrame.size.height+20);
    self.previewList.contentSize = self.preview.frame.size;
    self.previewList.pagingEnabled = NO;

    
    [self.previewList addSubview:self.preview];
    
//    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(biru:) name:@"1234" object:nil];

    
    //头部跳转用赋值
    super.super_VIN = self.proxyBasicInfoModel.VIN;
    super.super_owner_no = self.proxyBasicInfoModel.OWNER_NO;
//    self.previewList.contentSize = CGSizeMake(ScreenWidth, (_preview.bottomEdge)+);
    [self.view addSubview:self.previewList];
    
}
- (void)biru:(NSNotification *)NSNotification{
    //NSLog(@"%@",text.userInfo[@"orderid"]);
    NSLog(@"－－－－－接收到通知------");
}

#pragma mark 点击打印
- (void)clickPrintButton{
    BalancePresentController *presentCtr=[[BalancePresentController alloc]init];
    presentCtr.delegate=self;
    presentCtr.modalPresentationStyle = UIModalPresentationFormSheet;
    presentCtr.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    presentCtr.preferredContentSize=CGSizeMake(400, 300);;
    presentCtr.printType=ProxyPrintType;
    presentCtr.proxy_No=self.proxyBasicInfoModel.RO_NO;
    presentCtr.extimatePrice=[NSString stringWithFormat:@"%.2f",[self.proxyBasicInfoModel.REAL_TOTAL_AMOUNT doubleValue]];
    [self presentViewController:presentCtr animated:YES completion:nil];
//    //打印
//    [ICrEAMTool ipadPrintWithPrintType:ProxyPrintType printId:self.proxyBasicInfoModel.RO_NO Controller:self];
}
-(void)printProxyWithType:(PrintType) printType roNum:(NSString *)proxy_No extimatePrice:(NSString *)extimatePrice{
    [ICrEAMTool ipadPrintWithPrintType:printType printId:proxy_No Controller:self andEstimatePrice:extimatePrice];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
   
}



@end
